/*******************************************************************************
 * Copyright (c) 2013-2017 Lorenzo Bettini.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   Lorenzo Bettini - Initial contribution and API
 *******************************************************************************/

/*
* generated by Xtext
*/
package org.eclipse.xsemantics.dsl.ui.labeling

import com.google.inject.Inject
import org.eclipse.xsemantics.dsl.util.XsemanticsUtils
import org.eclipse.xsemantics.dsl.xsemantics.AbstractFieldDefinition
import org.eclipse.xsemantics.dsl.xsemantics.AuxiliaryDescription
import org.eclipse.xsemantics.dsl.xsemantics.AuxiliaryFunction
import org.eclipse.xsemantics.dsl.xsemantics.Axiom
import org.eclipse.xsemantics.dsl.xsemantics.CheckRule
import org.eclipse.xsemantics.dsl.xsemantics.JudgmentDescription
import org.eclipse.xsemantics.dsl.xsemantics.Rule
import org.eclipse.xsemantics.dsl.xsemantics.RuleWithPremises
import org.eclipse.xsemantics.dsl.xsemantics.XsemanticsSystem
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider
import org.eclipse.xtext.util.Strings
import org.eclipse.xtext.xbase.ui.labeling.XbaseLabelProvider

/**
 * Provides labels for a EObjects.
 * 
 * see http://www.eclipse.org/Xtext/documentation.html#labelProvider
 */
class XsemanticsLabelProvider extends XbaseLabelProvider {

	@Inject extension XsemanticsUtils

	@Inject
	new(AdapterFactoryLabelProvider delegate) {
		super(delegate);
	}

	def text(Rule rule) {
		val judgmentDescription = rule.getJudgmentDescription();
		if (judgmentDescription === null)
			return rule.getName;
		return rule.getName()
				+ " (" + Strings.emptyIfNull(judgmentDescription.getName()) + ")";
	}

	def text(CheckRule rule) {
		return rule.getName();
	}

	def text(AuxiliaryFunction aux) {
		val desc = aux.getAuxiliaryDescription();
		if (desc === null)
			return aux.getName;
		return aux.getName() + " (" + Strings.emptyIfNull(desc.getName()) + ")";
	}

	def image(Axiom axiom) {
		return "axiom.gif";
	}

	def image(RuleWithPremises rule) {
		return "rule.gif";
	}

	def image(CheckRule rule) {
		return "checkrule.gif";
	}

	def image(XsemanticsSystem ts) {
		return "system.gif";
	}

	def image(JudgmentDescription desc) {
		return "judgment.gif";
	}

	def image(AuxiliaryFunction aux) {
		return "auxfun.gif";
	}

	def image(AuxiliaryDescription aux) {
		return "auxdesc.gif";
	}

	def image(AbstractFieldDefinition f) {
		return "field_public_obj.gif";
	}
}
